package com.boc.langxiang.ui.fragment.shop;


import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.boc.langxiang.R;
import com.boc.langxiang.manager.PicassoImageLoader;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * MyLinearLayout simple {@link Fragment} subclass.
 */
public class PhotoFragment extends Fragment {

    @BindView(R.id.image_iv)
    ImageView imageIv;
    private String mImageUrl;

    private View rootView;

    private View.OnClickListener mOnClickListener;

    public PhotoFragment() {
        // Required empty public constructor
    }

    public static PhotoFragment getInstance(String imageUrl) {
        PhotoFragment fragment = new PhotoFragment();
        fragment.mImageUrl = imageUrl;
        return fragment;
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        rootView = inflater.inflate(R.layout.fragment_photo, container, false);
        ButterKnife.bind(this, rootView);
        init();
        return rootView;
    }

    private void init() {
        PicassoImageLoader.getInstance().displayUrlImage(getContext(), mImageUrl, imageIv);
        imageIv.setOnClickListener(mOnClickListener);
    }

    public void setOnClickListener(View.OnClickListener onClickListener) {
        this.mOnClickListener = onClickListener;
    }
}
